<?php
/**
 * Created by PhpStorm.
 * User: 764432054@qq.com
 * Date: 2020/5/20
 * Time: 23:05
 */
$ip = "0.0.0.0";
$port = $argv[1];
$sockefd = socket_create(AF_INET,SOCK_STREAM,0);
echo $sockefd.PHP_EOL;
$pid = posix_getpid();
echo "pid=".$pid.PHP_EOL;
echo `ls -al /proc/{$pid}/fd`;//为了方便看该进程生成的数据
socket_bind($sockefd,$ip,$port);
socket_listen($sockefd,5);

while (1){
    $connfd = socket_accept($sockefd);
    echo $connfd.PHP_EOL;
    socket_write($connfd,"hello,php 是世界上是好的语言");
}